package com.songlanyun.modules.shareconfig.controller.admin;

import com.songlanyun.common.annotation.RepeatSubmit;
import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.shareconfig.entity.SystemShareConfig;
import com.songlanyun.modules.shareconfig.model.dto.SystemShareConfigDTO;
import com.songlanyun.modules.shareconfig.service.SystemShareConfigService;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 会员分享提成配置表
 *
 * @author zx
 * @date 2021年3月4日 09:45:34
 */
@RestController
@RequestMapping("admin/config/share")
public class SystemShareConfigAdminController extends AbstractController {
    @Autowired
    private SystemShareConfigService systemShareConfigService;

    /**
     * 商家设置会员分享提成配置
     */
    @SysLog("商家设置会员分享提成配置")
    @PutMapping("/save")
    @RepeatSubmit(value = "3")
    public R set(@RequestBody SystemShareConfigDTO dto){
        Long shopId = getShopId(true);
		systemShareConfigService.set(shopId,dto);
        return R.ok();
    }


    /**
     * 获取商家的会员分享提成配置
     */
    @GetMapping("/load")
    public R load(){
        SystemShareConfig config = systemShareConfigService.loadByShopId(getShopId(true));
        return R.ok().put("config",config);
    }

}
